﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace game
{
    public static class VertexFormats
    {
        [StructLayout(LayoutKind.Sequential)]
        public struct VertexPosition2Texture
        {
            public Vector3 Position;
            public Vector2 TexCoord1;
            public Vector2 TexCoord2;

            public static VertexElement[] VertexElements;
            public static VertexDeclaration VertexDecl;
            public static int SizeInBytes { get; private set; }

            public VertexPosition2Texture(Vector3 position, Vector2 texCoord1, Vector2 texCoord2)
            {
                this.Position = position;
                this.TexCoord1 = texCoord1;
                this.TexCoord2 = texCoord2;
            }

            static VertexPosition2Texture()
            {
                VertexElements = new VertexElement[] {
                    new VertexElement(0, 0, VertexElementFormat.Vector3, VertexElementMethod.Default, VertexElementUsage.Position, 0),
                    new VertexElement(0, 12, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 0),
                    new VertexElement(0, 20, VertexElementFormat.Vector2, VertexElementMethod.Default, VertexElementUsage.TextureCoordinate, 1),
                };

                VertexDecl = new VertexDeclaration(ShooterGame.Instance.GraphicsDevice, VertexElements);

                SizeInBytes = 12 + 8 + 8;
            }

        }
    }
}
